﻿@{
    ViewBag.Title = "OtherClassConfig";
    Layout = "~/Views/Shared/_ScheduleClass_View.cshtml";
}

@section headerPartial {
    <div class="modal fade" id="myModalUserInfo" tabindex="-1" role="dialog" aria-hidden="false" data-backdrop="static" data-keyboard="false">
        <div class="modal-dialog">
            <div class="modal-content" id="modal1">
                <div class="modal-header">
                    <button id="btnClose" type="button" class="close" data-dismiss="modal" style="display: none;">
                        ×
                   
                    </button>
                    <div class="modal-title">
                        <b>完善信息，免费获得排课秘籍</b>
                    </div>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" role="form">
                        <div class="form-group">
                            <label for="list_school_name" class="col-sm-2 control-label">*学校全称</label>
                            <div class="col-sm-9" style="height: 55px;">
                                <div>
                                    <input id="list_school_name" type="text" class="form-control" placeholder="学校全称" aria-describedby="basic-addon1" maxlength="20"
                                        style="display: inline;">
                                </div>
                                <span id="inputError1" for="list_school_name" class="label label-danger" style="visibility: hidden">学校全称必填</span>
                            </div>
                            <br>
                            <br>
                            <label for="list_area" class="col-sm-2 control-label">*所在地区</label>
                            <div class="col-sm-9" style="height: 55px;">
                                <link rel="stylesheet" href="/Static/Template/js/city-picker.css">
                                <script src="/Static/Template/js/city-picker.data.js"></script>
                                <script src="/Static/Template/js/city-picker.js"></script>
                                <div data-toggle="city-picker" class="form-control city-picker-input">
                                    <input id="list_area" readonly="" type="text">
                                </div>
                                <span class="city-picker-span" style="width: 1440px; height: 34px; line-height: 33px;">
                                    <span class="placeholder">请选择地区</span>
                                    <span class="title1" style="display: none;"></span>
                                    <div class="arrow"></div>
                                </span>
                                <div class="city-picker-dropdown" style="left: 0px; top: 100%; width: 1440px;">
                                    <div class="city-select-wrap">
                                        <div class="city-select-tab">
                                            <a class="active" data-count="province">省份</a>
                                            <a data-count="city">城市</a>
                                            <a data-count="district">区县</a>
                                        </div>
                                        <div class="city-select-content">
                                            <div class="city-select province" data-count="province" style="display: block;">
                                                <dl class="clearfix">
                                                    <dt>A-G</dt>
                                                    <dd>
                                                        <a title1="安徽省" data-code="340000" class="">安徽省</a>
                                                        <a title1="北京市" data-code="110000" class="">北京市</a>
                                                        <a title1="重庆市" data-code="500000" class="">重庆市</a>
                                                        <a title1="福建省" data-code="350000" class="">福建省</a>
                                                        <a title1="甘肃省" data-code="620000" class="">甘肃省</a>
                                                        <a title1="广东省" data-code="440000" class="">广东省</a>
                                                        <a title1="广西壮族自治区" data-code="450000" class="">广西壮族自治区</a>
                                                        <a title1="贵州省" data-code="520000" class="">贵州省</a>
                                                    </dd>
                                                </dl>
                                                <dl class="clearfix">
                                                    <dt>H-K</dt>
                                                    <dd>
                                                        <a title1="海南省" data-code="460000" class="">海南省</a>
                                                        <a title1="河北省" data-code="130000" class="">河北省</a>
                                                        <a title1="黑龙江省" data-code="230000" class="">黑龙江省</a>
                                                        <a title1="河南省" data-code="410000" class="">河南省</a>
                                                        <a title1="湖北省" data-code="420000" class="">湖北省</a>
                                                        <a title1="湖南省" data-code="430000" class="">湖南省</a>
                                                        <a title1="江苏省" data-code="320000" class="">江苏省</a>
                                                        <a title1="江西省" data-code="360000" class="">江西省</a>
                                                        <a title1="吉林省" data-code="220000" class="">吉林省</a>
                                                    </dd>
                                                </dl>
                                                <dl class="clearfix">
                                                    <dt>L-S</dt>
                                                    <dd>
                                                        <a title1="辽宁省" data-code="210000" class="">辽宁省</a>
                                                        <a title1="内蒙古自治区" data-code="150000" class="">内蒙古自治区</a>
                                                        <a title1="宁夏回族自治区" data-code="640000" class="">宁夏回族自治区</a>
                                                        <a title1="青海省" data-code="630000" class="">青海省</a>
                                                        <a title1="山东省" data-code="370000" class="">山东省</a>
                                                        <a title1="上海市" data-code="310000" class="">上海市</a>
                                                        <a title1="山西省" data-code="140000" class="">山西省</a>
                                                        <a title1="陕西省" data-code="610000" class="">陕西省</a>
                                                        <a title1="四川省" data-code="510000" class="">四川省</a>
                                                    </dd>
                                                </dl>
                                                <dl class="clearfix">
                                                    <dt>T-Z</dt>
                                                    <dd>
                                                        <a title1="天津市" data-code="120000" class="">天津市</a>
                                                        <a title1="新疆维吾尔自治区" data-code="650000" class="">新疆维吾尔自治区</a>
                                                        <a title1="西藏自治区" data-code="540000" class="">西藏自治区</a>
                                                        <a title1="云南省" data-code="530000" class="">云南省</a>
                                                        <a title1="浙江省" data-code="330000" class="">浙江省</a>
                                                    </dd>
                                                </dl>
                                            </div>
                                            <div class="city-select city" data-count="city" style="display: none;">
                                                <dl class="clearfix">
                                                    <dd></dd>
                                                </dl>
                                            </div>
                                            <div class="city-select district" data-count="district" style="display: none;">
                                                <dl class="clearfix">
                                                    <dd></dd>
                                                </dl>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <span id="inputError2" for="list_area" class="label label-danger" style="visibility: hidden">所在地区必填(省份、城市、区县)</span>
                            </div>
                            <br>
                            <br>
                            <label for="schoolType" class="col-sm-2 control-label">*学校类型</label>
                            <div class="col-sm-9" style="height: 55px;">
                                <div>
                                    <select id="schoolType" class="form-control">
                                        <option value="-1" selected="selected">选择学校类型</option>
                                        <option value="0">小学</option>
                                        <option value="1">初中</option>
                                        <option value="2">高中</option>
                                        <option value="3">完全中学</option>
                                        <option value="4">大学</option>
                                        <option value="5">培训机构</option>
                                        <option value="6">竞品公司</option>
                                        <option value="7">其他</option>
                                    </select>
                                </div>
                                <span id="inputError6" for="schoolType" class="label label-danger" style="visibility: hidden">学校类型必选</span>
                            </div>
                            <br>
                            <br>
                            <hr style="width: 100%; height: 1px; float: left;">
                            <div>
                                <label for="list_job" class="col-sm-2 control-label">*您的职务</label>
                                <div class="col-sm-9" style="height: 55px; width: 165px;">
                                    <div>
                                        <select id="list_job" class="form-control">
                                            <option value="-1" selected="selected">选择您的职务</option>
                                            <option value="0">教务处负责人</option>
                                            <option value="1">信息负责人</option>
                                            <option value="2">年级主任</option>
                                            <option value="3">教学组长</option>
                                            <option value="4">理科教师</option>
                                            <option value="5">文科教师</option>
                                            <option value="6">教学副校长</option>
                                        </select>
                                    </div>
                                    <span id="inputError7" for="list_job" class="label label-danger" style="visibility: hidden">职务必选</span>
                                </div>
                                <label for="list_age" class="col-sm-2 control-label">*您的年龄</label>
                                <div class="col-sm-9" style="height: 55px; width: 165px;">
                                    <div>
                                        <select id="list_age" class="form-control">
                                            <option value="-1" selected="selected">选择您的年龄</option>
                                            <option value="0">20岁-25岁</option>
                                            <option value="1">25岁-30岁</option>
                                            <option value="2">30岁-35岁</option>
                                            <option value="3">35岁-40岁</option>
                                            <option value="4">40岁-45岁</option>
                                            <option value="5">45岁-50岁</option>
                                            <option value="6">50岁以上</option>
                                        </select>
                                    </div>
                                    <span id="inputError8" for="list_age" class="label label-danger" style="visibility: hidden">年龄必选</span>
                                </div>
                            </div>
                            <br>
                            <br>
                            <label for="list_phone" class="col-sm-2 control-label">*联系电话</label>
                            <div class="col-sm-9" style="height: 55px;">
                                <div>
                                    <input id="list_phone" type="text" class="form-control" placeholder="联系电话" aria-describedby="basic-addon1" maxlength="11"
                                        style="display: inline;">
                                </div>
                                <span id="inputError3" for="list_phone" class="label label-danger" style="visibility: hidden">无效联系电话</span>
                            </div>
                            <br>
                            <br>
                            <label for="list_qq" class="col-sm-2 control-label">联系QQ</label>
                            <div class="col-sm-9" style="height: 55px;">
                                <div>
                                    <input id="list_qq" type="text" class="form-control" placeholder="" aria-describedby="basic-addon1" maxlength="20">
                                </div>
                                <span id="inputError4" for="list_qq" class="label label-danger" style="visibility: hidden">无效QQ号</span>
                            </div>
                            <br>
                            <br>
                            <label for="list_mail" class="col-sm-2 control-label">联系邮箱</label>
                            <div class="col-sm-9" style="height: 55px;">
                                <div>
                                    <input id="list_mail" type="text" class="form-control" placeholder="" aria-describedby="basic-addon1" maxlength="100">
                                </div>
                                <span id="inputError5" for="list_mail" class="label label-danger" style="visibility: hidden">无效联系邮箱</span>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <!--<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>-->
                    <button id="btn_save_user_Info" type="button" class="btn btn-primary" onclick="userInfoEditor.inputUserInfo()">确定</button>
                </div>
            </div>
        </div>
        <input type="hidden" id="oldProvince">
        <input type="hidden" id="oldCity">
        <input type="hidden" id="oldDistrict">
    </div>
    <script>
        var userInfoEditor = new UserInfoEditor();
        $('#myModalUserInfo').on('show.bs.modal', function (e) {

            $(this).find('.modal-dialog').css({
                'margin-top': function () {
                    $("#inputError1").css({ 'visibility': 'hidden' });
                    $("#inputError2").css({ 'visibility': 'hidden' });
                    $("#inputError3").css({ 'visibility': 'hidden' });
                    $("#inputError4").css({ 'visibility': 'hidden' });
                    $("#inputError5").css({ 'visibility': 'hidden' });
                    $("#inputError6").css({ 'visibility': 'hidden' });
                    $("#inputError7").css({ 'visibility': 'hidden' });
                    $("#inputError8").css({ 'visibility': 'hidden' });
                    jQuery.ajax({
                        type: "GET",
                        url: "/m/userInfo/getUserInfo",
                        cache: false,
                        success: function (ret) {
                            var info = JSON.parse(ret);
                            $(".city-picker-span").css("width", "100%");
                            $(".city-picker-dropdown").css("width", "100%");
                            if (info.area != null && info.area != "" && info.area != undefined) {
                                $("#list_age").val(info.area);
                                var areaArray = info.area.split("-");

                                if (areaArray.length >= 3) {
                                    $("span .placeholder").css("display", "none");
                                    $("span .title1").css("display", "");
                                    $("span .title1").empty();
                                    $("#oldProvince").val(areaArray[0]);
                                    $("#oldCity").val(areaArray[1]);
                                    $("#oldDistrict").val(areaArray[2]);
                                    $("span .title1").append("<span class='select-item' data-count='province'>" + areaArray[0] + "</span>-");
                                    $("span .title1").append("<span class='select-item' data-count='city'>" + areaArray[1] + "</span>-");
                                    $("span .title1").append("<span class='select-item' data-count='district'>" + areaArray[2] + "</span>");
                                } else if (areaArray.length >= 2) {
                                    $("span .title1").empty();
                                    $("span .placeholder").css("display", "none");
                                    $("#oldProvince").val(areaArray[0]);
                                    $("#oldCity").val(areaArray[1]);
                                    $("span .title1").append("<span class='select-item' data-count='province'>" + areaArray[0] + "</span>-");
                                    $("span .title1").append("<span class='select-item' data-count='city'>" + areaArray[1] + "</span>");
                                } else if (areaArray.length >= 1) {
                                    $("span .title1").empty();
                                    $("#oldProvince").val(areaArray[0]);
                                    $("span .placeholder").css("display", "none");
                                    $("span .title1").append("<span class='select-item' data-count='province'>" + areaArray[0] + "</span>");
                                }
                                $("#btnClose").removeAttr("style");
                            }
                            if (info.schoolName != null && info.schoolName != "" && info.schoolName != undefined) {
                                $("#list_school_name").val(info.schoolName);
                            }
                            if (info.phone != null && info.phone != "" && info.phone != undefined) {
                                $("#list_phone").val(info.phone);
                            }
                            if (info.qqNumber != null && info.qqNumber != "" && info.qqNumber != undefined) {
                                $("#list_qq").val(info.qqNumber);
                            }
                            if (info.userEmail != null && info.userEmail != "" && info.userEmail != undefined) {
                                $("#list_mail").val(info.userEmail);
                            }
                            if (info.ageArrange != null && info.ageArrange != undefined && info.ageArrange.toString() != "") {
                                $("#list_age").val(info.ageArrange);
                            }
                            if (info.jobType != null && info.jobType != undefined && info.jobType.toString() != "") {
                                $("#list_job").val(info.jobType);
                            }
                            if (info.schoolType != null && info.schoolType != undefined && info.schoolType.toString() != "") {
                                $("#schoolType").val(info.schoolType);
                            }
                        }
                    });
                    $("#list_school_name").focus(function () {
                        $("#inputError1").css({ 'visibility': 'hidden' });
                    });
                    $("#list_area").focus(function () {
                        $("#inputError2").css({ 'visibility': 'hidden' });
                    });
                    $("#list_phone").focus(function () {
                        $("#inputError3").css({ 'visibility': 'hidden' });
                    });
                    $("#list_qq").focus(function () {
                        $("#inputError4").css({ 'visibility': 'hidden' });
                    });
                    $("#list_mail").focus(function () {
                        $("#inputError5").css({ 'visibility': 'hidden' });
                    });
                    $("#schoolType").change(function () {
                        $("#inputError6").css({ 'visibility': 'hidden' });
                    });
                    $("#list_job").change(function () {
                        $("#inputError7").css({ 'visibility': 'hidden' });
                    });
                    $("#list_age").change(function () {
                        $("#inputError8").css({ 'visibility': 'hidden' });
                    });
                    var modalHeight = 580; // $('#myModal').find('.modal-dialog').height();
                    return ($(window).height() / 2 - (modalHeight / 2));
                }
            });
        });
    </script>

    <script>
        var _hmt = _hmt || [];
        (function () {
            var hm = document.createElement("script");
            hm.src = "//hm.baidu.com/hm.js?7c66c07d4e8cc54deba8d7f967efe75b";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();
        $(document).ready(function () {
            updateSchoolView();
        });
        function loadInputTable() {
            if (userInfoEditor) {
                userInfoEditor.showUserInfoInput();
            }
        }

        function updateSchoolView() {
            var schoolLabel = $("#label_school_name");
            jQuery.ajax({
                type: "GET",
                url: "/m/userInfo/getSchoolName",
                cache: false,
                success: function (ret) {
                    var userInfoButton = $("#btn_add_userInfo");
                    userInfoButton.css({ 'visibility': 'visible' });
                    if (ret.split(",")[0] == "") {
                        //从未填写过学校信息
                        userInfoButton.text("添加");
                        $("#btn_add_task").attr('disabled', true);
                        $("#btn_add_task_first").attr('disabled', true);
                        schoolLabel.text("学校: 未填写");
                        loadInputTable();
                    } else {
                        userInfoButton.text("修改");
                        $("#btn_add_task").attr('disabled', false);
                        $("#btn_add_task_first").attr('disabled', false);
                        schoolLabel.text("学校: " + ret.split(",")[0]);
                        if (ret.split(",")[1] == "") {
                            loadInputTable();
                        }
                    }
                    schoolLabel.css({ 'visibility': 'visible' });
                }
            });
        }
    </script>
}



  <div id="divbody" style="min-height: 495px;">
        <div class="container" id="divcon">
            <style type="text/css">
                .rule-menu-area {
                    border-right: 1px solid #ccc;
                }

                .rule-table>tbody>tr>td {
                    vertical-align: middle;
                    text-align: center;
                }

                td.rule-value-checked {
                    background-color: #f5f5f5;
                }
            </style>
            <style>
                a.view-course-plan {
                    padding-left: 25px;
                    background-repeat: no-repeat;
                    margin-left: 10px;
                    text-decoration: none;
                    padding-bottom: 5px;
                }



                li.pos {
                    margin-left: 15px;
                }

                .list-inline a {
                    text-decoration: none;
                    padding-left: 25px;
                    padding-bottom: 5px;
                }
            </style>
            <div class="row" style="margin-top: 20px;">
                <div class="col-md-8">
                    <ul class="list-inline">
                        <li>
                            <a href="javascript:void()" id="baseInfo" onclick="goUrl(&#39;/m/baseInfo/index?taskId=2640188197994496&#39;)" class="task-baseInfo">
                            基础信息</a>
                        </li>
                        <li class="pos">
                            <a href="javascript:void()" id="rule" onclick="goUrl(&#39;/m/rule/unScheduleRule?taskId=2640188197994496&#39;)" class="task-rule active task-rule-active">
                            规则条件</a>
                        </li>
                        <li class="pos">
                            <a href="javascript:void()" id="preAssignment" onclick="goUrl(&#39;/m/courseplan/preschedule?taskId=2640188197994496&#39;)"
                                class="task-preAssignment"> 预排</a>
                        </li>
                        <li class="pos">
                            <a href="javascript:void()" id="auto" onclick="goUrl(&#39;/m/courseplan/start?taskId=2640188197994496&#39;)" class="task-auto">
                            自动排课</a>
                        </li>
                        <li class="pos" show-by-courseplan="1" style="display: none;">
                            <a id="adjust" class="task-adjust" href="http://paike.yunxiao.com/m/adjustTeaCoursePlan/teaTimeTable?taskId=2640188197994496#c">调课</a>
                        </li>
                        <li class="pos" show-by-courseplan="1" style="display: none;">
                            <a href="http://paike.yunxiao.com/m/courseplan/class?taskId=2640188197994496" id="task-coursePlan" class="task-coursePlan">查看课表</a>
                        </li>

                    </ul>
                </div>

                <div class="col-md-2 col-md-offset-2">
                    <div class="dropdown" style="float: right;">
                        <button id="btnQuestions" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-default dropdown-toggle">
                            排课遇到难题
                            <span class="caret"></span>
                        </button>
                        <ul id="questions-list" class="dropdown-menu dropdown-menu-right" aria-labelledby="btnQuestions">
                        </ul>
                    </div>
                </div>
            </div>

            <script src="/Static/Template/js/course-plan.js" charset="utf-8"></script>
            <script>
                var coursePlanService = new CoursePlanService();
                var hasCoursePlan = 0;
                $(function () {
                    initButton();
                })
                function initButton() {
                    coursePlanService.hasCoursePlan(taskId, function (has) {
                        hasCoursePlan = has;
                        $("li[show-by-courseplan='1']").hide();
                        if (has == "1") {
                            $("li[show-by-courseplan='1']").show();
                        }
                    })
                }
            </script>

            <script>
                function fillQuestion(list) {
                    var html = new Array();
                    for (var i = 0; i < list.length; i++) {
                        html.push("<li><a href='" + list[i].text + "' target='_blank'>" + list[i].title + "</a></li>");
                    }
                    $("#questions-list").html(html.join(""));
                }

                function getContentList(sign) {
                    jQuery.ajax({
                        url: "/m/content?sign=" + sign,
                        type: "GET",
                        success: function (ret) {
                            if (ret) {
                                fillQuestion(ret);
                            } else {
                                $("#questions-list").html("<li><a href='http://bbs.yunxiao.com/forum.php?mod=forumdisplay&fid=36'" +
                                    " target='_blank'>暂时没有内容，前往论坛</a></li>");
                            }
                        }
                    })
                }
            </script>
            <div class="row">
                <div class="col-md-8" style="padding-top: 10px;">
                    请设置学校教学时间、年级/班级固定无课时间、课程/教师固定无课时间以及连堂课和合班课
                </div>
            </div>
            <div style="margin-top:10px;border-top: 1px solid #0599f7"></div>

            <style type="text/css">
                .my-list-inline {
                    padding-left: 0;
                    list-style: none;
                    border-bottom: 1px solid #b3b3b3;
                    display: inline-block;
                }

                .my-list-inline>li {
                    display: inline-block;
                    width: 104px;
                    text-align: center;
                    margin-left: -4px;
                    cursor: pointer;
                }

                .my-list-inline>li:first-child {
                    margin-left: 0px;
                }

                .my-list-inline .active {
                    color: #ec5d41;
                    border-bottom: 4px solid #ec5d41;
                    cursor: default;
                }

                .my-list-inline a {
                    color: #666666;
                    font-size: 13px;
                    text-decoration: none;
                }

                a.colorful {
                    color: #ec5d41;
                }

                a.view-unSchedule-rule {
                    text-decoration: none;
                }
            </style>
            <div class="row" style="margin-top: 20px;">
                <div class="col-md-8">
                    <ul class="my-list-inline">
                        <li id="task-rule-unScheduleTime">
                            <a href="http://paike.yunxiao.com/m/rule/unScheduleRule?taskId=2640188197994496">不排课时间</a>
                        </li>
                        <li id="task-rule-doubleLessons">
                            <a href="http://paike.yunxiao.com/m/rule/doubleLessonRule?taskId=2640188197994496"> 不连堂</a>
                        </li>
                        <li id="task-rule-mergedClasses">
                            <a href="http://paike.yunxiao.com/m/rule/mergedclass?taskId=2640188197994496">合班</a>
                        </li>
                        <li id="task-rule-other" class="active">
                            <a href="http://paike.yunxiao.com/m/rule/japq?taskId=2640188197994496" class="colorful">其它</a>
                        </li>
                        <li id="task-rule-list">
                            <a href="javascript:ruleViewer.getRuleList(true)">规则列表</a>
                        </li>
                    </ul>
                </div>
            </div>

            <div class="row" style="margin-top: 10px">
                <div class="col-md-2 rule-menu-area">
                    <style>
                        .rule-menu {
                            list-style: none;
                            margin-left: -40px;
                        }

                        .rule-menu li {
                            margin: 5px 0px;
                        }

                        .rule-menu li a.active {
                            color: #ff0000;
                        }
                    </style>
                    <ul class="rule-menu">
                        <li>
                            <a name="japq" class="active">教案平齐</a>
                        </li>
                        <li>
                            <a href="http://paike.yunxiao.com/m/rule/zrkfb?taskId=2640188197994496" name="zrkfb">周任课分布</a>
                        </li>
                        <li>
                            <a href="http://paike.yunxiao.com/m/rule/rrkfb?taskId=2640188197994496" name="rrkfb">日任课分布</a>
                        </li>
                        <li>
                            <a href="http://paike.yunxiao.com/m/rule/lsxz?taskId=2640188197994496" name="lsxz">连上限制</a>
                        </li>
                        <li>
                            <a href="http://paike.yunxiao.com/m/rule/sdfp?taskId=2640188197994496" name="sdfp">时段分配</a>
                        </li>
                    </ul>
                    <script>
                        function setCurrentRuleMenu(name) {
                            $("a[name='" + name + "']").addClass("active");
                            $("a[name='" + name + "']").removeAttr("href");
                        }
                    </script> </div>
                <div class="col-md-10">
                    <div>
                        <ul class="list-inline form-group-sm">
                            <li>
                                <select class="form-control" id="selGrade" onchange="selectGrade()" style="width:120px;">
                                </select>
                            </li>
                            <li>
                                <select id="selCourse" class="form-control" style="width:200px;" onchange="changeCourse()">
                                    <option value="0">全部课程</option>
                                </select>
                            </li>
                            <li style="font-size: 13px;">
                                教案平齐：张三老师教完1班教2班，而不是1班上了两节课后2班才上1节课
                            </li>
                        </ul>

                    </div>
                    <div>
                        <table id="rule-table" class="table table-bordered rule-table">
                            <tbody>
                                <tr>
                                    <td rowspan="2">课程</td>
                                    <td rowspan="2">老师</td>
                                    <td colspan="3">重要程度</td>
                                </tr>
                                <tr>
                                    <td>
                                        <label>
                                            <input type="radio" name="importance" value="5"> 特别重要</label>
                                    </td>
                                    <td>
                                        <label>
                                            <input type="radio" name="importance" value="3"> 相对重要</label>
                                    </td>
                                    <td>
                                        <label>
                                            <input type="radio" name="importance" value="1"> 一般</label>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            <div id="stepArea" style="height: 70px;">
                <div id="stepBox" class="text-right stepBoxFixed2" style="bottom: 57px;">
                    <button type="button" class="btn btn-info btn-sm" onclick="goUrl(&#39;/m/rule/mergedclass?taskId=2640188197994496&#39;)">
                        上一步
                    </button>
                    <button type="button" class="btn btn-info btn-sm" onclick="goUrl(&#39;/m/courseplan/preschedule?taskId=2640188197994496&#39;)">
                        下一步
                    </button>
                </div>
            </div>
            <link href="/Static/Template/css/step-box.css" rel="stylesheet">
            <script type="text/javascript" src="/Static/Template/js/step-box.js"></script>
            <script>
                stepBox.init();
            </script>
            <link href="/Static/Template/css/ruleDialog.css" rel="stylesheet">
            <style>
                #ruleListTable_body td {
                    padding: 8px;
                    font-size: 14.8px;
                    text-align: left;
                }
            </style>
            <!--规则列表 Modal -->
            <div class="modal fade modal-ruleList" id="ruleListModal" tabindex="-1" role="dialog" aria-labelledby="ruleListModalLabel"
                aria-hidden="false">
                <div class="modal-dialog" style="width: 900px">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal">
                                <span aria-hidden="true">×</span>
                            </button>
                            <div class="modal-title" id="ruleListModalLabel">
                                <b>规则列表</b>
                            </div>
                            <div style="margin-top: 10px;">
                                <select id="unScheduleRuleListTypeSlt" onchange="ruleViewer.getRuleList()" class="form-control" style="margin-bottom: 10px; width: 200px;">
                                    <option value="all" selected="">所有规则</option>
                                    <option value="unschedule_grade">年级不排课</option>
                                    <option value="unschedule_class">班级不排课</option>
                                    <option value="unschedule_course">课程不排课</option>
                                    <option value="unschedule_course_grade">年级课程不排课</option>
                                    <option value="unschedule_teacher">教师不排课</option>
                                    <option value="preschedule">预排</option>
                                    <option value="importance_japq">教案平齐</option>
                                    <option value="importance_zrkfb">周任课分布</option>
                                    <option value="importance_rrkfb">日任课分布</option>
                                    <option value="importance_lsxz">连上限制</option>
                                </select>
                                <span id="ruleStatistics"></span>
                            </div>
                        </div>
                        <div class="modal-body">
                            <table class="table table-striped table-bordered">
                                <thead>
                                    <tr>
                                        <td width="130">规则</td>
                                        <td>细则</td>
                                        <td style="width: 100px">重要性</td>
                                        <td width="50">操作</td>
                                    </tr>
                                </thead>
                                <tbody id="ruleListTable_body">
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <script src="/Static/Template/js/rule-statistic.js" charset="UTF-8"></script>
            <script src="/Static/Template/js/rule-view.js" charset="UTF-8"></script>
            <script>
                var _hmt = _hmt || [];
                (function () {
                    var hm = document.createElement("script");
                    hm.src = "https://hm.baidu.com/hm.js?7c66c07d4e8cc54deba8d7f967efe75b";
                    var s = document.getElementsByTagName("script")[0];
                    s.parentNode.insertBefore(hm, s);
                })();
            </script>
            <script>
                var ruleViewer = new RuleViewer();
            </script>
            <script>
                var isMyTask = true
            </script>
            <script>
                ruleViewer.setTaskId('2640188197994496')
            </script>

            <script>
                var taskId = 2640188197994496;
                var isMyTask = true;
                $(function () {
                    // 1st leve step
                    setTaskStep("rule");
                    // 2nd level step
                    setTaskRuleStep("task-rule-other");

                    //
                    setCurrentRuleMenu("japq");
                })
            </script>
            <script type="text/javascript" src="/Static/Template/js/base-info.js"></script>
            <script type="text/javascript" src="/Static/Template/js/other-rule.js"></script>
            <script type="text/javascript" src="/Static/Template/js/otherRule.js"></script>

            <script>
                var baseInfo = new BaseInfo();
                var otherRule = new OtherRule();

                var importanceRuleType = "japq";
                var types = [
                    //        "必须保证", "9",
                    "特别重要", "5",
                    "相对重要", "3",
                    "一般", "1"];

                var defaultValue = "5";

                var ruleList = [];

                $(function () {
                    // 加载规则列表
                    loadRuleList(function () {
                        var gradeId = getSelectedGradeId();
                        // 加载课程数据
                        loadCourses(gradeId, function () {
                            changeCourse();
                        });
                    });

                    // 绑定全选事件
                    bindCheckAllEvents();
                });

                /**
                 * 加载规则列表
                 */
                function loadRuleList(callback) {
                    // 加载所有的课程老师
                    baseInfo.getCourseTeacherListBy(taskId, 0, 0, function (courseTeachers) {
                        // 加载已有的规则
                        otherRule.getImportanceRules(taskId, importanceRuleType, function (importanctRules) {
                            buildRuleList(courseTeachers, importanctRules);
                            callback();
                        })
                    })
                }

                /**
                 * 加载规则列表数据
                 */
                function buildRuleList(courseTeachers, importanctRules) {
                    for (var i = 0; i < courseTeachers.length; i++) {
                        var courseTeacher = courseTeachers[i];
                        var id = createdRuleId(courseTeacher);
                        var gradeId = courseTeacher.gradeId;
                        var courseId = courseTeacher.courseId;
                        var teacherId = courseTeacher.teacherId;

                        // 加载已设置的值
                        var value = defaultValue;
                        var valueChanged = 0;
                        if (importanctRules != null) {
                            for (var j = 0; j < importanctRules.length; j++) {
                                var importanceRule = importanctRules[j];
                                if (importanceRule.id == id) {
                                    value = importanceRule.value;
                                    valueChanged = 1;
                                }
                            }
                        }

                        var rule = {};
                        rule.id = id;
                        rule.gradeId = gradeId;
                        rule.courseId = courseId;
                        rule.courseName = courseTeacher.courseName;
                        rule.teacherId = teacherId;
                        rule.teacherName = courseTeacher.teacherName;
                        rule.value = value;
                        rule.courseTeacherIndex = i;
                        rule.valueChanged = valueChanged;
                        ruleList.push(rule);
                    }
                }

                function createdRuleId(courseTeacher) {
                    return courseTeacher.id;
                }

                // 点击年级触发
                function selectGrade() {
                    var gradeId = getSelectedGradeId();
                    loadCourses(gradeId, function () {
                        changeCourse();
                    });
                }

                // 获取选择的年级Id
                function getSelectedGradeId() {
                    var gradeId = $("#selGrade").val()
                    return gradeId;
                }

                // 加载年级课程
                function loadCourses(gradeId, callback) {
                    var defaultText = "全部课程";
                    var colSelect = $("#selCourse");
                    baseInfo.getCourseListByGradeId(taskId, gradeId, function (courseList) {
                        loadItems(colSelect, courseList, defaultText, "0");
                        callback();
                    });
                }

                // 改变课程时触发
                function changeCourse() {
                    var gradeId = getSelectedGradeId();
                    var courseId = $("#selCourse").val();
                    renderRules(gradeId, courseId);

                    setCheckAllStatus("importance");
                }

                // 渲染页面规则数据
                function renderRules(gradeId, courseId) {
                    // 移除原来的规则
                    clearRule();

                    var htmls = [];
                    for (var i = 0; i < ruleList.length; i++) {
                        var rule = ruleList[i];

                        if (rule.gradeId != gradeId) {
                            continue;
                        }

                        if (courseId != "0" && rule.courseId != courseId) {
                            continue;
                        }

                        var couId = rule.courseId;
                        var teacherId = rule.teacherId;
                        var id = rule.id;

                        htmls.push("<tr name='rule-table-line' id='" + id + "' courseId='" + couId + "'>");
                        htmls.push("<td>" + rule.courseName + "</td>");
                        htmls.push("<td>" + rule.teacherName + "</td>");
                        for (var ii = 0; ii < types.length; ii = ii + 2) {
                            var type = types[ii];
                            var value = types[ii + 1]
                            var checked = "";
                            var classStyle = ""
                            if (value == rule.value) {
                                checked = "checked='checked'";
                                classStyle = "class='rule-value-checked'";
                            }
                            htmls.push("<td " + classStyle + ">" +
                                "<input type='radio' name='line_" + id + "' typeName='importance' ruleId='" + id + "' value='" + value + "' " + checked + ">" +
                                " " + type + "</td>");
                        }
                        htmls.push("</tr>");
                    }

                    var html = htmls.join("");
                    var table = $("#rule-table");
                    table.append(html);

                    // 绑定事件
                    bindSelectImportanceEvents();
                }

                // 清除现有规则数据
                function clearRule() {
                    $("tr[name='rule-table-line']").remove();
                }

                /**
                 * 绑定全选事件
                 */
                function bindCheckAllEvents() {
                    $("input[name='importance']").on("click", checkAll);
                }

                /**
                 * 全选
                 */
                function checkAll() {
                    var the = $(this);
                    var value = the.val();
                    var name = the.attr("name")

                    $("input[typeName='" + name + "']").each(function () {
                        var checkedCol = $(this);
                        if (checkedCol.attr("value") == value) {
                            checkedCol.prop("checked", "checked");
                            checkTypeCol(checkedCol);
                        }
                    })

                    // 保存
                    saveRule();
                }

                /**
                 * 绑定事件
                 */
                function bindSelectImportanceEvents() {
                    $("tr[name='rule-table-line']").delegate("input[type='radio']", "click", checkType);
                }

                /**
                 *
                 */
                function checkType() {
                    var the = $(this);
                    checkTypeCol(the);
                    // 保存
                    saveRule();

                    setCheckAllStatus("importance");
                }

                function checkTypeCol(col) {
                    var ruleId = col.attr("ruleId");
                    var value = col.attr("value")
                    var inputName = col.attr("name");

                    // 移除原来选择值得背景色
                    $("input[name='" + inputName + "']").parent("td").removeClass("rule-value-checked")

                    // 设置当前选择值得背景色
                    col.parent("td").addClass("rule-value-checked");

                    setRuleValue(ruleId, value);
                }

                /**
                 * 设置规则值
                 * @@param id
                 * @@param value
                 */
                 function setRuleValue(id, value) {
                     for (var i = 0; i < ruleList.length; i++) {
                         var rule = ruleList[i];
                         if (rule.id == id) {
                             rule.value = value;
                             rule.valueChanged = 1;
                             return;
                         }
                     }
                 }

                 /**
                  * 保存规则
                  */
                 function saveRule() {

                     if (!isMyTask) {
                         return;
                     }

                     var rules = [];
                     for (var i = 0; i < ruleList.length; i++) {
                         var rule = ruleList[i];

                         //  值改变过的要保存
                         if (rule.valueChanged == 0) {
                             continue;
                         }

                         var item = {};
                         item.id = rule.id;
                         item.gradeId = rule.gradeId;
                         item.courseId = rule.courseId;
                         item.teacherId = rule.teacherId;
                         item.value = rule.value;

                         rules.push(item);
                     }

                     var data = JSON.stringify(rules);
                     otherRule.saveImportanceRule(taskId, importanceRuleType, data, function (ret) {
                         if (ret == 0) {
                             alert("保存失败，请重试！");
                         }
                     })
                 }

            </script>
        </div>
    </div>